package com.dianning.web.action.ticket;

import java.util.ArrayList;
import java.util.Date;
import java.util.List;

import org.apache.commons.lang.StringUtils;
import org.apache.commons.logging.*;

import com.dianning.bean.Area;
import com.dianning.bean.ChannelContact;
import com.dianning.bean.Company;
import com.dianning.bean.Info;
import com.dianning.bean.InfoExpand;
import com.dianning.bean.Money;
import com.dianning.bean.Parameter;
import com.dianning.bean.Profile;
import com.dianning.bean.Resume;
import com.dianning.bean.TradingArea;
import com.dianning.bean.UserDetail;
import com.dianning.bean.UserInfo;
import com.dianning.bean.Visitor;
import com.dianning.comm.ChannelConfig;
import com.dianning.comm.Constant;
import com.dianning.comm.DianningUtil;
import com.dianning.comm.OrderObj;
import com.dianning.comm.Util;
import com.dianning.exception.DianningException;
import com.dianning.service.AreaService;
import com.dianning.service.ChannelService;
import com.dianning.service.InfoService;
import com.dianning.service.ParameterService;
import com.dianning.service.UserInfoService;
import com.dianning.service.VisitorService;
import com.dianning.service.web.PageList;
import com.dianning.service.web.Pages;
import com.dianning.web.action.BaseAction;
import com.dianning.web.interceptor.RemoteAddrAware;
import com.dianning.web.interceptor.UserSessionAware;
import com.dianning.web.servlet.UserSession;
import com.dianning.web.ui.OptionsLong;
import com.dianning.web.ui.OptionsString;

public class Piao extends BaseAction implements UserSessionAware{

	private static final Log logger = LogFactory.getLog(Piao.class);
	
	private InfoService infoService;
	private ChannelService channelService;
	private ParameterService parameterService;
	private AreaService areaService;
	private UserInfoService userInfoService;


	public InfoService getInfoService() {
		return infoService;
	}

	public void setInfoService(InfoService infoService) {
		this.infoService = infoService;
	}
	
	public ChannelService getChannelService() {
		return channelService;
	}

	public void setChannelService(ChannelService channelService) {
		this.channelService = channelService;
	}

	public ParameterService getParameterService() {
		return parameterService;
	}

	public void setParameterService(ParameterService parameterService) {
		this.parameterService = parameterService;
	}

	public AreaService getAreaService() {
		return areaService;
	}

	public void setAreaService(AreaService areaService) {
		this.areaService = areaService;
	}

	public UserInfoService getUserInfoService() {
		return userInfoService;
	}

	public void setUserInfoService(UserInfoService userInfoService) {
		this.userInfoService = userInfoService;
	}
	
	private UserSession userSession;

	public UserSession getUserSession() {
		return userSession;
	}

	public void setUserSession(UserSession userSession) {
		this.userSession = userSession;
	}
	
	private List ticketPiaoTypeList = new ArrayList();
	private List xiaoshiList = new ArrayList();
	private List fenzhongList = new ArrayList();
	private List zhangshuList = new ArrayList();


	private void setTicketPiaoTypeListValues(){
		List l = this.getParameterService().findParameters("ticketPiaoType", 2, null, "orders", 0);
		for(int i=0;i<l.size();i++){
			Parameter p = (Parameter) l.get(i);
			ticketPiaoTypeList.add(new OptionsLong(p.getId(), p.getParamName()));
		}
	}
	private void setXiaoshiListValues(){
		xiaoshiList.add(new OptionsString("01", "01"));
		xiaoshiList.add(new OptionsString("02", "02"));
		xiaoshiList.add(new OptionsString("03", "03"));
		xiaoshiList.add(new OptionsString("04", "04"));
		xiaoshiList.add(new OptionsString("05", "05"));
		xiaoshiList.add(new OptionsString("06", "06"));
		xiaoshiList.add(new OptionsString("07", "07"));
		xiaoshiList.add(new OptionsString("08", "08"));
		xiaoshiList.add(new OptionsString("09", "09"));
		xiaoshiList.add(new OptionsString("10", "10"));
		xiaoshiList.add(new OptionsString("11", "11"));
		xiaoshiList.add(new OptionsString("12", "12"));
		xiaoshiList.add(new OptionsString("13", "13"));
		xiaoshiList.add(new OptionsString("14", "14"));
		xiaoshiList.add(new OptionsString("15", "15"));
		xiaoshiList.add(new OptionsString("16", "16"));
		xiaoshiList.add(new OptionsString("17", "17"));
		xiaoshiList.add(new OptionsString("18", "18"));
		xiaoshiList.add(new OptionsString("19", "19"));
		xiaoshiList.add(new OptionsString("20", "20"));
		xiaoshiList.add(new OptionsString("21", "21"));
		xiaoshiList.add(new OptionsString("22", "22"));
		xiaoshiList.add(new OptionsString("23", "23"));
		xiaoshiList.add(new OptionsString("00", "00"));
	}
	private void setFenzhongListValues(){
		fenzhongList.add(new OptionsString("00", "00"));
		fenzhongList.add(new OptionsString("05", "05"));
		fenzhongList.add(new OptionsString("10", "10"));
		fenzhongList.add(new OptionsString("15", "15"));
		fenzhongList.add(new OptionsString("20", "20"));
		fenzhongList.add(new OptionsString("25", "25"));
		fenzhongList.add(new OptionsString("30", "30"));
		fenzhongList.add(new OptionsString("35", "35"));
		fenzhongList.add(new OptionsString("40", "40"));
		fenzhongList.add(new OptionsString("45", "45"));
		fenzhongList.add(new OptionsString("50", "50"));
		fenzhongList.add(new OptionsString("55", "55"));
	}
	private void setZhangshuListValues(){
		zhangshuList.add(new OptionsLong(1, "1张"));
		zhangshuList.add(new OptionsLong(2, "2张"));
		zhangshuList.add(new OptionsLong(3, "3张"));
		zhangshuList.add(new OptionsLong(4, "4张"));
		zhangshuList.add(new OptionsLong(5, "多张"));
	}
	
	
	private void initValues(){
		setTicketPiaoTypeListValues();
		setXiaoshiListValues();
		setFenzhongListValues();
		setZhangshuListValues();
		this.setBigChannel(this.getChannelService().findChannelContactById(this.bid));
		this.setSmallChannel(this.getChannelService().findChannelContactById(this.sid));
		this.setArea(this.getAreaService().findAreaById(this.areaId));
		if(this.areaId == -1){
			this.areaId = 0;
		}
		if(this.tid == -1){
			this.tid = 0;
		}
		this.setTradingArea(this.getAreaService().findTradingAreaById(this.tid));
	}
	
	private long id;
	private long bid = ChannelConfig.TICKET_ID;
	private long sid = ChannelConfig.TICKET_PIAO_ID;
	private long areaId = -1;
	private long allTop = 1;
	private long tid = -1;
	private String title = "";
	private int isbiz = -1;
	private boolean biz = false;
	private boolean profile = true;
	private String content;
	private List photo;
	private int photonum;
	private String linkman;
	private String phone;
	
	private long objtype = 0;
	private long ticketPiaoType = -1;
	private String riqi;
	private String xiaoshi;
	private String fenzhong;
	private String changguan;
	private long zhangshu;
	private String zuowei;
	private String minPrice="";
	private String maxPrice="";
	
	public long getId() {
		return id;
	}

	public void setId(long id) {
		this.id = id;
	}

	public long getBid() {
		return bid;
	}

	public void setBid(long bid) {
		this.bid = bid;
	}

	public long getSid() {
		return sid;
	}

	public void setSid(long sid) {
		this.sid = sid;
	}public long getAreaId() {
		return areaId;
	}

	public void setAreaId(long areaId) {
		this.areaId = areaId;
	}

	public long getAllTop() {
		return allTop;
	}

	public void setAllTop(long allTop) {
		this.allTop = allTop;
	}


	public long getTid() {
		return tid;
	}

	public void setTid(long tid) {
		this.tid = tid;
	}

	public String getTitle() {
		return title;
	}

	public void setTitle(String title) {
		this.title = title;
	}

	public long getObjtype() {
		return objtype;
	}

	public void setObjtype(long objtype) {
		this.objtype = objtype;
	}

	public List getTicketPiaoTypeList() {
		return ticketPiaoTypeList;
	}

	public void setTicketPiaoTypeList(List ticketPiaoTypeList) {
		this.ticketPiaoTypeList = ticketPiaoTypeList;
	}

	public List getXiaoshiList() {
		return xiaoshiList;
	}

	public void setXiaoshiList(List xiaoshiList) {
		this.xiaoshiList = xiaoshiList;
	}

	public List getFenzhongList() {
		return fenzhongList;
	}

	public void setFenzhongList(List fenzhongList) {
		this.fenzhongList = fenzhongList;
	}

	public List getZhangshuList() {
		return zhangshuList;
	}

	public void setZhangshuList(List zhangshuList) {
		this.zhangshuList = zhangshuList;
	}

	public long getTicketPiaoType() {
		return ticketPiaoType;
	}

	public void setTicketPiaoType(long ticketPiaoType) {
		this.ticketPiaoType = ticketPiaoType;
	}

	public String getRiqi() {
		return riqi;
	}

	public void setRiqi(String riqi) {
		this.riqi = riqi;
	}

	public String getXiaoshi() {
		return xiaoshi;
	}

	public void setXiaoshi(String xiaoshi) {
		this.xiaoshi = xiaoshi;
	}

	public String getFenzhong() {
		return fenzhong;
	}

	public void setFenzhong(String fenzhong) {
		this.fenzhong = fenzhong;
	}

	public String getChangguan() {
		return changguan;
	}

	public void setChangguan(String changguan) {
		this.changguan = changguan;
	}

	public long getZhangshu() {
		return zhangshu;
	}

	public void setZhangshu(long zhangshu) {
		this.zhangshu = zhangshu;
	}

	public String getZuowei() {
		return zuowei;
	}

	public void setZuowei(String zuowei) {
		this.zuowei = zuowei;
	}

	public String getMinPrice() {
		return minPrice;
	}

	public void setMinPrice(String minPrice) {
		this.minPrice = minPrice;
	}

	public String getMaxPrice() {
		return maxPrice;
	}

	public void setMaxPrice(String maxPrice) {
		this.maxPrice = maxPrice;
	}

	public String getContent() {
		return content;
	}

	public void setContent(String content) {
		this.content = content;
	}

	public String getLinkman() {
		return linkman;
	}

	public void setLinkman(String linkman) {
		this.linkman = linkman;
	}

	public String getPhone() {
		return phone;
	}

	public void setPhone(String phone) {
		this.phone = phone;
	}

	public int getIsbiz() {
		return isbiz;
	}

	public void setIsbiz(int isbiz) {
		this.isbiz = isbiz;
	}

	public boolean isBiz() {
		return biz;
	}

	public void setBiz(boolean biz) {
		this.biz = biz;
	}

	public boolean isProfile() {
		return profile;
	}

	public void setProfile(boolean profile) {
		this.profile = profile;
	}


	public List getPhoto() {
		return photo;
	}

	public void setPhoto(List photo) {
		this.photo = photo;
	}

	public int getPhotonum() {
		return photonum;
	}

	public void setPhotonum(int photonum) {
		this.photonum = photonum;
	}
	
	private Info info;
	private List sameAreas;
	private List sameUsers;
	private PageList pageList;
	private List areas;
	private String domain = Constant.DOMAIN;
	private String profileDomain = Constant.PROFILE_DOMAIN;
	private ChannelContact bigChannel;
	private ChannelContact smallChannel;
	private Area area;
	private TradingArea tradingArea;
	private List ticketPiaoTypes;
	
	public Info getInfo() {
		return info;
	}

	public void setInfo(Info info) {
		this.info = info;
	}
	
	public List getSameAreas() {
		return sameAreas;
	}

	public void setSameAreas(List sameAreas) {
		this.sameAreas = sameAreas;
	}

	public List getSameUsers() {
		return sameUsers;
	}

	public void setSameUsers(List sameUsers) {
		this.sameUsers = sameUsers;
	}

	public PageList getPageList() {
		return pageList;
	}

	public void setPageList(PageList pageList) {
		this.pageList = pageList;
	}

	public List getAreas() {
		return areas;
	}

	public void setAreas(List areas) {
		this.areas = areas;
	}
	

	public String getDomain() {
		return domain;
	}

	public void setDomain(String domain) {
		this.domain = domain;
	}

	public String getProfileDomain() {
		return profileDomain;
	}

	public void setProfileDomain(String profileDomain) {
		this.profileDomain = profileDomain;
	}

	public ChannelContact getBigChannel() {
		return bigChannel;
	}

	public void setBigChannel(ChannelContact bigChannel) {
		this.bigChannel = bigChannel;
	}

	public ChannelContact getSmallChannel() {
		return smallChannel;
	}

	public void setSmallChannel(ChannelContact smallChannel) {
		this.smallChannel = smallChannel;
	}

	public Area getArea() {
		return area;
	}

	public void setArea(Area area) {
		this.area = area;
	}

	public TradingArea getTradingArea() {
		return tradingArea;
	}

	public void setTradingArea(TradingArea tradingArea) {
		this.tradingArea = tradingArea;
	}


	public List getTicketPiaoTypes() {
		return ticketPiaoTypes;
	}

	public void setTicketPiaoTypes(List ticketPiaoTypes) {
		this.ticketPiaoTypes = ticketPiaoTypes;
	}

	public String execute() {
		try {
			return this.executeMethod(this.getAction());
		} catch (Exception e) {
			logger.error(e);
			return ERROR;
		}
	}

	public String index(){
		this.setInfo(this.getInfoService().findInfoById(this.id));
		if(this.getInfo() == null){
			return "infodisable";
		}else{
			if(this.getInfo().getValidated() == 2){
				return "infodisable";
			}
		}
		this.setSameAreas(this.getInfoService().findInfos(id,-1, this.getInfo().getCcid(), 1, 1, -1, "addTime", 1, 1, 5));
		this.setSameUsers(this.getInfoService().findInfos(id,this.getInfo().getUid(), this.getInfo().getCcid(), 1, 1, -1, "addTime", 1, 1, 5));
        return "index";
	}
	
	public String list(){
		if(this.areaId == 0){
			this.areaId = -1;
		}
		if(this.tid == 0){
			this.tid = -1;
		}
		this.setAreas(this.getAreaService().findAreas("orders", 0));
		this.setTicketPiaoTypes(this.getParameterService().findParameters("ticketPiaoType", 2, null, "orders", 0));
		Pages pages = new Pages();
		pages.setPage(this.getPage());
		pages.setPerPageNum(Constant.PAGE_NUM);
		if (this.getTotal() > 0) {
			pages.setTotalNum(this.getTotal());
		}
		pages.setFileName("/ticket/piao.action?action=list&areaId="+this.areaId+"&tid="+this.tid+"&isbiz="+this.isbiz+"&objtype="+this.objtype+"&ticketPiaoType="+this.ticketPiaoType+"&minPrice="+this.minPrice+"&maxPrice="+this.maxPrice+"&title="+this.title);
		List wherein = new ArrayList();
		if(this.objtype != -1){
			wherein.add("keyword='objtype' and ivalue="+this.objtype);		
		}
		if(StringUtils.isNotBlank(minPrice)){
			wherein.add("keyword='minPrice' and ivalue>="+(int)(Float.parseFloat(minPrice)*10));
		}
		if(StringUtils.isNotBlank(maxPrice)){
			wherein.add("keyword='minPrice' and ivalue<="+(int)(Float.parseFloat(maxPrice)*10));
		}
		if(ticketPiaoType != -1){
			wherein.add("keyword='ticketPiaoType' and ivalue=" + ticketPiaoType);
		}
		OrderObj commend = new OrderObj();
		commend.setOrderBy("isCommend");
		commend.setAscOrDesc(1);
		OrderObj top = new OrderObj();
		if(this.areaId == -1){
			top.setOrderBy("isCityTop");
			top.setAscOrDesc(1);
		}else{
			this.allTop = -1;
			top.setOrderBy("isAreaTop");
			top.setAscOrDesc(1);
		}
		OrderObj up = new OrderObj();
		up.setOrderBy("upTime");
		up.setAscOrDesc(1);
		OrderObj[] oo = {commend,top,up};
		this.setPageList(this.getInfoService().findInfos(-1, -1, sid, areaId, tid, isbiz, 1, 1,-1,title, wherein, oo, pages));
		return "list";
	}
	public String post(){
		initValues();
		this.setAction("dopost");
		UserInfo ui = this.getUserInfoService().findUserInfoByUid(userSession.getUid());
		this.setLinkman(ui.getName());
		this.setPhone(ui.getUserDetail().getMobile());
		return "post";
	}
	
	public String dopost(){
		ChannelContact cc = this.getChannelService().findChannelContactById(this.sid);
		Info info = new Info();
		info.setCid(cc.getChannelId());
		info.setCcid(this.sid);
		info.setTitle(DianningUtil.filterKeyword(this.title));
		info.setContent(DianningUtil.filterKeyword(this.content));
		info.setAreaId(this.areaId);
		info.setTradingareaId(this.tid);
		info.setUid(this.userSession.getUid());
		info.setName(this.linkman);
		info.setTel(this.phone);
		info.setIsbiz(boolean2int(this.biz));
		info.setIsProfile(boolean2int(this.profile));
		info.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			info.setPhotonum(0);
		}else{
			info.setPhotonum(this.photo.size());
		}
		info.setAvatar("");
		info.setValidated(0);
		info.setStatus(1);
		info.setAddTime(new Date());
		info.setUpTime(new Date());
		info.setIsCityTop(0);
		info.setCityTopTime(new Date());
		info.setIsAreaTop(0);
		info.setAreaTopTime(new Date());
		info.setIsCommend(0);
		info.setCommendTime(new Date());
		
		List infoExpands = new ArrayList();
		//objtype
		InfoExpand infoObjtype = new InfoExpand();
		infoObjtype.setKeyword("objtype");
		if(this.objtype==0){
			infoObjtype.setSvalue("出售");
		}
		if(this.objtype==1){
			infoObjtype.setSvalue("求购");
		}
		infoObjtype.setIvalue(this.objtype);
		infoExpands.add(infoObjtype);
		//ticketPiaoType
		Parameter pPiaoType = this.getParameterService().findParameterById(this.ticketPiaoType);
		InfoExpand infoPiaoType = new InfoExpand();
		infoPiaoType.setKeyword("ticketPiaoType");
		infoPiaoType.setSvalue(pPiaoType.getParamName());
		infoPiaoType.setIvalue(this.ticketPiaoType);
		infoExpands.add(infoPiaoType);
		//riqi
		InfoExpand infoRiqi = new InfoExpand();
		infoRiqi.setKeyword("riqi");
		infoRiqi.setSvalue(this.riqi);
		infoRiqi.setIvalue(0);
		infoExpands.add(infoRiqi);
		//xiaoshi
		InfoExpand infoXiaoshi = new InfoExpand();
		infoXiaoshi.setKeyword("xiaoshi");
		infoXiaoshi.setSvalue(this.xiaoshi);
		if(StringUtils.isBlank(this.xiaoshi)){
			infoXiaoshi.setIvalue(0);
		}else{
			infoXiaoshi.setIvalue(Long.parseLong(this.xiaoshi));
		}
		infoExpands.add(infoXiaoshi);
		//fenzhong
		InfoExpand infoFenzhong = new InfoExpand();
		infoFenzhong.setKeyword("fenzhong");
		infoFenzhong.setSvalue(this.fenzhong);
		if(StringUtils.isBlank(this.fenzhong)){
			infoFenzhong.setIvalue(0);
		}else{
			infoFenzhong.setIvalue(Long.parseLong(this.fenzhong));
		}
		infoExpands.add(infoFenzhong);
		//changguan
		InfoExpand infoChangguan = new InfoExpand();
		infoChangguan.setKeyword("changguan");
		infoChangguan.setSvalue(this.changguan);
		infoChangguan.setIvalue(0);
		infoExpands.add(infoChangguan);
		//zhangshu
		InfoExpand infoZhangshu = new InfoExpand();
		infoZhangshu.setKeyword("zhangshu");
		infoZhangshu.setSvalue(String.valueOf(this.zhangshu));
		infoZhangshu.setIvalue(this.zhangshu);
		infoExpands.add(infoZhangshu);
		//zuowei
		InfoExpand infoXuowei = new InfoExpand();
		infoXuowei.setKeyword("zuowei");
		infoXuowei.setSvalue(this.zuowei);
		infoXuowei.setIvalue(0);
		infoExpands.add(infoXuowei);
		//minPrice
		InfoExpand infoMinPrice = new InfoExpand();
		infoMinPrice.setKeyword("minPrice");
		infoMinPrice.setSvalue(this.minPrice);
		if(StringUtils.isBlank(this.minPrice)){
			infoMinPrice.setIvalue(0);
		}else{
			infoMinPrice.setIvalue((int)(Float.parseFloat(minPrice)*10));
		}
		infoExpands.add(infoMinPrice);
		//maxPrice
		InfoExpand infoMaxPrice = new InfoExpand();
		infoMaxPrice.setKeyword("maxPrice");
		infoMaxPrice.setSvalue(this.maxPrice);
		if(StringUtils.isBlank(this.maxPrice)){
			infoMaxPrice.setIvalue(0);
		}else{
			infoMaxPrice.setIvalue((int)(Float.parseFloat(maxPrice)*10));
		}
		infoExpands.add(infoMaxPrice);
		
		info = this.getInfoService().saveInfo(info, infoExpands);
		this.id = info.getId();
		return "dopost";
	}
	

	public String update(){
		
		this.setAction("doupdate");
		this.setInfo(this.getInfoService().findInfoById(this.id));
		if(this.getInfo() == null){
			return "infodisable";
		}else{
			if(this.getInfo().getValidated() == 2){
				return "infodisable";
			}
		}
		ChannelContact cc = this.getChannelService().findChannelContactById(this.sid);
		this.bid = cc.getParentId();
		this.sid = this.info.getCcid();
		this.areaId = this.info.getAreaId();
		this.tid = this.info.getTradingareaId();
		this.title = this.info.getTitle();
		this.content = this.info.getContent();
		this.linkman = this.info.getName();
		this.phone = this.info.getTel();
		this.biz = int2boolean(this.info.getIsbiz());
		this.profile = int2boolean(this.info.getIsProfile());
		this.photo = this.info.getPhoto();
		this.photonum = this.info.getPhotonum();

		//objtype
		InfoExpand infoObjtype = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "objtype");
		this.objtype = infoObjtype.getIvalue();
				
		//ticketPiaoType
		InfoExpand infoPiaoType = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "ticketPiaoType");
		this.ticketPiaoType = infoPiaoType.getIvalue();
		//riqi
		InfoExpand infoRiqi = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "riqi");
		this.riqi = infoRiqi.getSvalue();
		//xiaoshi
		InfoExpand infoXiaoshi = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "xiaoshi");
		this.xiaoshi = infoXiaoshi.getSvalue();
		//fenzhong
		InfoExpand infoFenzhong = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "fenzhong");
		this.fenzhong = infoFenzhong.getSvalue();
		//changguan
		InfoExpand infoChangguan = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "changguan");
		this.changguan = infoChangguan.getSvalue();
		//zhangshu
		InfoExpand infoZhangshu = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "zhangshu");
		this.zhangshu = infoZhangshu.getIvalue();
		//zuowei
		InfoExpand infoZuowei = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "zuowei");
		this.zuowei = infoZuowei.getSvalue();		
		//minPrice
		InfoExpand infoMinPrice = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "minPrice");
		if(infoMinPrice.getIvalue()!=0){
			this.minPrice = infoMinPrice.getSvalue();
		}
		//maxPrice
		InfoExpand infoMaxPrice = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "maxPrice");
		if(infoMinPrice.getIvalue()!=0){
			this.maxPrice = infoMaxPrice.getSvalue();
		}
		initValues();
		return "update";
	}
	
	public String doupdate(){
		ChannelContact cc = this.getChannelService().findChannelContactById(this.sid);
		Info info = this.getInfoService().findInfoById(this.id);
		info.setCid(cc.getChannelId());
		info.setCcid(this.sid);
		info.setTitle(DianningUtil.filterKeyword(this.title));
		info.setContent(DianningUtil.filterKeyword(this.content));
		info.setAreaId(this.areaId);
		info.setTradingareaId(this.tid);
		info.setUid(this.userSession.getUid());
		info.setName(this.linkman);
		info.setTel(this.phone);
		info.setIsbiz(boolean2int(this.biz));
		info.setIsProfile(boolean2int(this.profile));
		info.setPhoto(this.photo);
		if(this.photo==null || this.photo.isEmpty()){
			info.setPhotonum(0);
		}else{
			info.setPhotonum(this.photo.size());
		}
		
		List infoExpands = new ArrayList();
		//objtype
		InfoExpand infoObjtype = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "objtype");
		infoObjtype.setKeyword("objtype");
		if(this.objtype==0){
			infoObjtype.setSvalue("出售");
		}
		if(this.objtype==1){
			infoObjtype.setSvalue("求购");
		}
		infoObjtype.setIvalue(this.objtype);
		infoExpands.add(infoObjtype);
		
		//ticketPiaoType
		Parameter pPiaoType = this.getParameterService().findParameterById(this.ticketPiaoType);
		InfoExpand infoPiaoType = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "ticketPiaoType");
		infoPiaoType.setKeyword("ticketPiaoType");
		infoPiaoType.setSvalue(pPiaoType.getParamName());
		infoPiaoType.setIvalue(this.ticketPiaoType);
		infoExpands.add(infoPiaoType);
		//riqi
		InfoExpand infoRiqi = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "riqi");
		infoRiqi.setKeyword("riqi");
		infoRiqi.setSvalue(this.riqi);
		infoRiqi.setIvalue(0);
		infoExpands.add(infoRiqi);
		//xiaoshi
		InfoExpand infoXiaoshi = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "xiaoshi");
		infoXiaoshi.setKeyword("xiaoshi");
		infoXiaoshi.setSvalue(this.xiaoshi);
		if(StringUtils.isBlank(this.xiaoshi)){
			infoXiaoshi.setIvalue(0);
		}else{
			infoXiaoshi.setIvalue(Long.parseLong(this.xiaoshi));
		}
		infoExpands.add(infoXiaoshi);
		//fenzhong
		InfoExpand infoFenzhong = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "fenzhong");
		infoFenzhong.setKeyword("fenzhong");
		infoFenzhong.setSvalue(this.fenzhong);
		if(StringUtils.isBlank(this.fenzhong)){
			infoFenzhong.setIvalue(0);
		}else{
			infoFenzhong.setIvalue(Long.parseLong(this.fenzhong));
		}
		infoExpands.add(infoFenzhong);
		//changguan
		InfoExpand infoChangguan = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "changguan");
		infoChangguan.setKeyword("changguan");
		infoChangguan.setSvalue(this.changguan);
		infoChangguan.setIvalue(0);
		infoExpands.add(infoChangguan);
		//zhangshu
		InfoExpand infoZhangshu = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "zhangshu");
		infoZhangshu.setKeyword("zhangshu");
		infoZhangshu.setSvalue(String.valueOf(this.zhangshu));
		infoZhangshu.setIvalue(this.zhangshu);
		infoExpands.add(infoZhangshu);
		//zuowei
		InfoExpand infoXuowei = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "zuowei");
		infoXuowei.setKeyword("zuowei");
		infoXuowei.setSvalue(this.zuowei);
		infoXuowei.setIvalue(0);
		infoExpands.add(infoXuowei);
		//minPrice
		InfoExpand infoMinPrice = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "minPrice");
		infoMinPrice.setKeyword("minPrice");
		infoMinPrice.setSvalue(this.minPrice);
		if(StringUtils.isBlank(this.minPrice)){
			infoMinPrice.setIvalue(0);
		}else{
			infoMinPrice.setIvalue((int)(Float.parseFloat(minPrice)*10));
		}
		infoExpands.add(infoMinPrice);
		//maxPrice
		InfoExpand infoMaxPrice = this.getInfoService().findInfoExpandByInfoIdKeyword(this.id, "maxPrice");
		infoMaxPrice.setKeyword("maxPrice");
		infoMaxPrice.setSvalue(this.maxPrice);
		if(StringUtils.isBlank(this.maxPrice)){
			infoMaxPrice.setIvalue(0);
		}else{
			infoMaxPrice.setIvalue((int)(Float.parseFloat(maxPrice)*10));
		}
		infoExpands.add(infoMaxPrice);


		info = this.getInfoService().updateInfo(info, infoExpands);
		return "doupdate";
	}







}
